﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace DotNet.WebUI.BasicControl
{
    public partial class ProvinceCity : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnProvince_Click(object sender, EventArgs e)
        {
            string[] _Province = { "北京", "四川", "云南", "广东" };

            ddlProvince.DataSource = _Province;
            ddlProvince.DataBind();
        }

        protected void ddlProvince_SelectedIndexChanged(object sender, EventArgs e)
        {
            string[] _City = { "请选择州市" };
            if (ddlProvince.SelectedValue == "云南")
            {
                _City = new string[] { "请选择州市", "昆明市", "红河州", "大理州", "曲靖市" };
            }
            else if (ddlProvince.SelectedValue == "四川")
            {
                _City = new string[] { "请选择州市", "成都市", "乐山市", "雅安", "宜宾" };
            }
            else
            {
                _City = new string[] { "未定义州市" };
            }
            ddlCity.DataSource = _City;
            ddlCity.DataBind();
        }

        protected void ddlCity_SelectedIndexChanged(object sender, EventArgs e)
        {
            string[] _County = { "请选择县" };
            if (ddlCity.SelectedValue == "昆明市")
            {
                _County = new string[] { "请选择县", "五华区", "盘龙区", "安宁市", "嵩明县" };
            }
            else if (ddlCity.SelectedValue == "大理州")
            {
                _County = new string[] { "请选择县", "下关市", "祥云县", "巍山县", "洱源县" };
            }
            else if (ddlCity.SelectedValue == "红河州")
            {
                _County = new string[] { "请选择县", "蒙自市", "开远市", "河口县" };
            }
            else
            {
                _County = new string[] { "未定义县" };
            }
            ddlCounty.DataSource = _County;
            ddlCounty.DataBind();
        }

        protected void btnSelected_Click(object sender, EventArgs e)
        {
            txtInfo.Text = string.Format("您选择的省：{0} 州市： {1} 县: {2} ",
                ddlProvince.SelectedValue,
                ddlCity.SelectedValue,
                ddlCounty.SelectedValue);
            txtInfo.ReadOnly = txtInfo.Visible = true;
            txtInfo.BackColor = System.Drawing.Color.WhiteSmoke;
            txtInfo.ForeColor = System.Drawing.Color.IndianRed;
        }
    }
}